<%--
    用户申请消息列表
    Author: Zhelang
    Date: 2023-12-12
    Version: 1.0
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="m" uri="/WEB-INF/tld/mytag.tld"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>我的申请</title>
    <link rel="stylesheet" type="text/css" href="<c:url value='/resources/css/bootstrap.css'/>">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resources/css/style.css' />">
    <script src="<c:url value='/resources/js/bootstrap.bundle.js'/> "></script>
</head>
<body>
    <div class="page-container">
        <header>
            <jsp:include page="userHeader.jsp"/>
        </header>

        <div class="content">
            <div class="container" style="min-width: 750px;">
                <nav class="navbar bg-body-tertiary">
                    <div class="container-fluid">
                        <div class="fs-4 fw-bolder">我的申请列表</div>
                    </div>
                </nav>
                <!-- 我的application列表  -->
                <div class="list-group" style="min-width: 600px; ">
                    <br>
                    <c:if test="${not empty applications}">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th scope="col">申请时间</th>
                                <th scope="col">审核状态</th>
                                <th scope="col">申请描述</th>
                                <th scope="col"></th>
                            </tr>
                            </thead>
                            <c:forEach items="${applications}" var="application" varStatus="loop" begin="${(currentPage-1)*10}" end="${currentPage*10-1}">
                                <tr>
                                    <th scope="row"><fmt:formatDate value="${application.applicationTime}" pattern="yyyy-MM-dd HH:mm" /></th>
                                    <td>
                                        <c:if test="${application.status} == 0">审核中</c:if>
                                        <c:if test="${application.status} == 1">审核通过</c:if>
                                        <c:if test="${application.status} == -1">被拒绝</c:if>
                                    </td>
                                    <td>${application.description}</td>
                                </tr>
                            </c:forEach>
                        </table>
                    </c:if>
                    <c:if test="${empty applications}">
                        <p>&nbsp; 还没有申请</p>
                    </c:if>
                </div>

                <!-- 分页展示 -->
                <div class="d-flex justify-content-evenly">
                    <c:if test="${currentPage > 1}">
                        <div class="pre-page">
                            <a href="<c:url value='/user/applications?pageNo=${currentPage - 1}'/>" class="btn btn-outline-secondary">&lt; 上一页</a>
                        </div>
                    </c:if>
                    <c:if test="${currentPage <= 1}">
                        <div class="pre-page">
                            <a href="<c:url value='/user/applications?pageNo=${currentPage - 1}'/>" class="btn btn-outline-secondary disabled">&lt; 上一页</a>
                        </div>
                    </c:if>
                    <p>第 ${currentPage} 页</p>
                    <c:if test="${currentPage < totalPage}">
                        <div class="next-page">
                            <a href="<c:url value='/user/applications?pageNo=${currentPage + 1}'/>" class="btn btn-outline-secondary">下一页 &gt;</a>
                        </div>
                    </c:if>
                    <c:if test="${currentPage >= totalPage}">
                        <div class="next-page">
                            <a href="<c:url value='/user/applications?pageNo=${currentPage + 1}'/>" class="btn btn-outline-secondary disabled">下一页 &gt;</a>
                        </div>
                    </c:if>
                </div>
            </div>
        </div>

        <footer>
            <m:footer/>
        </footer>
    </div>
</body>
</html>
